package com.qf.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.pojo.Member;
import com.qf.pojo.Order;
import com.qf.pojo.Setmeal;
import org.apache.ibatis.annotations.*;

public interface OrderMapper extends BaseMapper<Order> {

    @Select("select * from t_order ${ew.customSqlSegment}")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "member_id",property = "member_id"),
            @Result(column = "setmeal_id",property = "setmeal_id"),
            @Result(column = "member_id",
                    property = "member",
                    javaType = Member.class,
                    one = @One(select = "com.qf.mapper.MemberMapper.findById")
            ),
            @Result(column = "setmeal_id",
                    property = "setmeal",
                    javaType = Setmeal.class,
                    one = @One(select = "com.qf.mapper.SetmealMapper.findById")
            )
    })
    IPage<Order> findPage(IPage<Order> page, @Param("ew") QueryWrapper qw);
}
